home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2004 March / PCWMAR04.iso / Software / Trial / TestTrack Pro 6 / ttprowininstall.exe / %LSMAINDIR% / LicenseServer Help / wwhelp / wwhimpl / common / scripts / switch.js < prev   
Encoding:
JavaScript  |  2003-12-12  |  5.1 KB  |  239 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHSwitch_Object()
  5. {
  6.   this.mParameters = "";
  7.   this.mbSingle    = false;
  8.   this.mbForceJS   = false;
  9.   this.mSettings   = new WWHCommonSettings_Object();
  10.  
  11.   this.fExec        = WWHSwitch_Exec;
  12.   this.fProcessURL  = WWHSwitch_ProcessURL;
  13.   this.fJavaEnabled = WWHSwitch_JavaEnabled;
  14.   this.fJavaCapable = WWHSwitch_JavaCapable;
  15.   this.fSwitch      = WWHSwitch_Switch;
  16. }
  17.  
  18. function  WWHSwitch_Exec(bParamNormalizeURL,
  19.                          ParamURL)
  20. {
  21.   var  TargetURL   = ParamURL;
  22.   var  bUseJava    = false;
  23.   var  FrameSetURL = "";
  24.  
  25.  
  26.   // Normalize URL if necessary
  27.   //
  28.   if (bParamNormalizeURL)
  29.   {
  30.     TargetURL = WWHStringUtilities_NormalizeURL(ParamURL);
  31.   }
  32.  
  33.   // Process parameters
  34.   //
  35.   this.fProcessURL(TargetURL);
  36.  
  37.   // Use single frame if specified
  38.   //
  39.   if (this.mbSingle)
  40.   {
  41.     FrameSetURL = "../../common/html/wwhelp.htm";
  42.   }
  43.   else
  44.   {
  45.     // Determine if Java version can be used
  46.     //
  47.     if (this.mbForceJS)
  48.     {
  49.       bUseJava = false;
  50.     }
  51.     else if (this.mSettings.mbForceJavaScript)
  52.     {
  53.       bUseJava = false;
  54.     }
  55.     else
  56.     {
  57.       // See if Java is enabled
  58.       //
  59.       if (this.fJavaEnabled())
  60.       {
  61.         bUseJava = this.fJavaCapable();
  62.       }
  63.     }
  64.  
  65.     // Pick frameset to use
  66.     //
  67.     if (bUseJava)
  68.     {
  69.       FrameSetURL = "../../java/html/wwhelp.htm";
  70.     }
  71.     else
  72.     {
  73.       FrameSetURL = "../../js/html/wwhelp.htm";
  74.     }
  75.   }
  76.  
  77.   // Switch to frameset
  78.   //
  79.   this.fSwitch(FrameSetURL);
  80. }
  81.  
  82. function  WWHSwitch_ProcessURL(ParamURL)
  83. {
  84.   // Reset members
  85.   //
  86.   this.mParameters = "";
  87.   this.mbSingle    = false;
  88.   this.mbForceJS   = false;
  89.  
  90.   if (ParamURL.indexOf("?") != -1)
  91.   {
  92.     var  Parts;
  93.     var  Parameters;
  94.  
  95.  
  96.     Parts = ParamURL.split("?");
  97.     Parameters = Parts[1];
  98.  
  99.     if (Parameters.indexOf("&") != -1)
  100.     {
  101.       var  MaxIndex;
  102.       var  Index;
  103.  
  104.  
  105.       // Reset parameters to drop single and forcejs if present
  106.       //
  107.       this.mParameters = "";
  108.  
  109.       Parts = Parameters.split("&");
  110.       for (MaxIndex = Parts.length, Index = 0 ; Index < MaxIndex ; Index++)
  111.       {
  112.         if (Parts[Index] == "single=true")
  113.         {
  114.           this.mbSingle = true;
  115.         }
  116.         else if (Parts[Index] == "forcejs=true")
  117.         {
  118.           this.mbForceJS = true;
  119.         }
  120.         else
  121.         {
  122.           if (this.mParameters.length > 0)
  123.           {
  124.             this.mParameters += "&";
  125.           }
  126.  
  127.           this.mParameters += Parts[Index];
  128.         }
  129.       }
  130.     }
  131.     else if (Parameters == "single=true")
  132.     {
  133.       this.mParameters = "";
  134.       this.mbSingle    = true;
  135.     }
  136.     else if (Parameters == "forcejs=true")
  137.     {
  138.       this.mParameters = "";
  139.       this.mbForceJS   = true;
  140.     }
  141.     else
  142.     {
  143.       this.mParameters = Parameters;
  144.     }
  145.  
  146.     // Prefix parameters with "?" if parameters exist
  147.     //
  148.     if (this.mParameters.length > 0)
  149.     {
  150.       this.mParameters = "?" + this.mParameters;
  151.     }
  152.   }
  153. }
  154.  
  155. function  WWHSwitch_JavaEnabled()
  156. {
  157.   var  bJavaEnabled = false;
  158.  
  159.  
  160.   // Check if Java is enabled
  161.   //
  162.   if ((typeof navigator != "undefined") &&
  163.       (navigator != null))
  164.   {
  165.     bJavaEnabled = navigator.javaEnabled();
  166.   }
  167.  
  168.   return bJavaEnabled;
  169. }
  170.  
  171. function  WWHSwitch_JavaCapable()
  172. {
  173.   var  bJavaCapable = false;
  174.   var  Browser  = WWHFrame.WWHBrowserInfo.mBrowser;
  175.   var  Platform = WWHFrame.WWHBrowserInfo.mPlatform;
  176.  
  177.  
  178.   // Determine if platform supports Java version
  179.   //
  180.   if (Browser == 1)  // Shorthand for Netscape
  181.   {
  182.     if (Platform == 1)  // Shorthand for Windows
  183.     {
  184.       bJavaCapable = true;  // Java works on NS for Windows
  185.     }
  186.     else if (Platform == 2)  // Shorthand for Macintosh
  187.     {
  188.       bJavaCapable = false;  // Java doesn't work on NS for Macintosh
  189.     }
  190.     else
  191.     {
  192.       bJavaCapable = false;  // Java is too slow on NS for UNIX
  193.     }
  194.   }
  195.   else if (Browser == 4)  // Shorthand for Netscape
  196.   {
  197.     // LiveConnect broken under Netscape 6.0 on Windows and Mac
  198.     //
  199.     bJavaCapable = false;  // Play it safe.
  200.   }
  201.   else  // Assume IE
  202.   {
  203.     if (Platform == 1)  // Shorthand for Windows
  204.     {
  205.       bJavaCapable = true;  // Java works on IE for Windows
  206.  
  207.       if (WWHFrame.WWHBrowserInfo.mbIEWindowsXP)
  208.       {
  209.         bJavaCapable = false;  // Java not included under Windows XP
  210.       }
  211.     }
  212.     else if (Platform == 2)  // Shorthand for Macintosh
  213.     {
  214.       bJavaCapable = false;  // LiveConnect not currently working on Macintosh
  215.     }
  216.     else
  217.     {
  218.       bJavaCapable = false;  // Java doesn't work on IE for UNIX
  219.     }
  220.   }
  221.  
  222.   return bJavaCapable;
  223. }
  224.  
  225. function  WWHSwitch_Switch(ParamFrameSetURL)
  226. {
  227.   var  SwitchURL;
  228.  
  229.  
  230.   // Add parameters to redirect
  231.   //
  232.   SwitchURL = ParamFrameSetURL + this.mParameters;
  233.  
  234.   // Switch to desired frameset
  235.   // Delay required since this page is processing the action
  236.   //
  237.   setTimeout("location.replace(\"" + WWHStringUtilities_EscapeURLForJavaScriptAnchor(SwitchURL) + "\");", 1);
  238. }
  239.